<?php
if ( PHP_SAPI === 'cli' )
{
	set_time_limit(0);

	for ($i = 1; $i < $_SERVER['argc']; $i++)
	{
		$arg = explode('=', $_SERVER['argv'][$i]);
		if (count($arg) > 1 || strncmp($arg[0], '-', 1) === 0)
		{
			$_GET[ltrim($arg[0], '-')] = isset($arg[1]) ? $arg[1] : true;
		}
		$_REQUEST = array_merge($_REQUEST,$_GET);
	}

	if ( empty($_REQUEST['pathinfo']) )
	{
		fwrite(STDOUT, "[error]: " . 'invalid param `pathinfo`' . PHP_EOL);
		return;
	}

	$_SERVER['PATH_INFO'] = $_REQUEST['pathinfo'];
	require_once __DIR__ . '/index.php';
}
else
{
	header("Status: 404 Not Found");
	exit;
}
